import MysqlServer from "../utils/connect";
import {ISqlInsert} from "../../global";

export const flowAddDao = async (params: Array<string>) => {
    return await MysqlServer.sqlAsync<ISqlInsert, Array<string>>("INSERT INTO t_flow(`flowUID`, `userUID`, `path`, `name`, `describe`, `time`) VALUES(?, ?, ?, ?, ?, ?)", params)
}

export interface IFlow {
    key: string
    flowUID: string;
    userUID: number;
    path: string;
    name: string
    describe: string
    time: string
}

export const flowListDao = async (params: Array<string>) => {
    return await MysqlServer.sqlAsync<Array<IFlow>, Array<string>>("SELECT * FROM t_flow WHERE userUID = ?", params)
}

export const flowViewDao = async (params: Array<string>) => {
    return await MysqlServer.sqlAsync<Array<IFlow>, Array<string>>("SELECT * FROM t_flow WHERE flowUID = ?", params)
}

export const flowDelDao = async (params: Array<string>) => {
    return await MysqlServer.sqlAsync<ISqlInsert, Array<string>>("DELETE FROM t_flow WHERE flowUID = ?", params)
}
